import { ApiCall } from "tsrpc";
import { ReqOutBattle, ResOutBattle } from "../../../shared/master/word/PtlOutBattle";
import { player } from "../../../model/fight/body/player";
import { template } from "../../../shared/master/MsgAction";

export default async function (call: ApiCall<ReqOutBattle, ResOutBattle>) {
    call.succ({})
    let user = call.req._player as player;
    let _battle = user.get_battle();
    if (!_battle) {
        user.sendMsg(template.default, '你还没有在任何战斗中.无需离开')
        return;
    }
    if (_battle.checkSpecial()) {
        user.sendMsg(template.default, '特殊战中,不可离开战斗')
        return;
    }
    _battle.out(user)
    user.sendMsg(template.default, '你已逃离战斗')
}